home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
4_12.lha
/
4_12
/
4_12a.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-08
|
887b
|
53 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
include <stream.h>
include <ctype.h>
/ print out a printable version of
/ the character read in
nt dochar()
char c;
if (!cin.get(c))
return 0;
if (isascii(c) && isprint(c))
{
cout.put(c);
cout.put('_');
}
else
cout << form("%2.2x", c);
return 1;
/ print a group of five characters
nt dogroup()
for (int chr_count = 5; chr_count-- > 0; )
if (!dochar())
return 0;
return 1;
/ Print out six groups of characters separated
/ by spaces. Precede each line with the count
/ of characters printed so far.
nt main(int, char**)
for (int chr_cnt = 0; cin; chr_cnt += 30)
{
cout << dec(chr_cnt, 5) << " ";
for (int grp_count = 6;
grp_count-- > 0 && dogroup(); )
cout << " ";
cout << "\n";
}
return 0;